package com.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.order.mapper.ProductCategoryMapper;
import com.order.pojo.ProductCategory;
import com.order.service.ProductCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
@Service
public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMapper,ProductCategory> implements ProductCategoryService {
    @Autowired
    ProductCategoryMapper productCategoryMapper;
    @Override
    public List<ProductCategory> findAll() {
        return productCategoryMapper.findAll();
    }

    @Override
    public PageInfo<ProductCategory> selectpage(int pageNum, int pageSize, ProductCategory productCategory) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper<ProductCategory>queryWrapper=new QueryWrapper<ProductCategory>();
        queryWrapper.like(true,"category_name",productCategory.getCategoryName());
        queryWrapper.eq("del",0);
        List<ProductCategory> courselist=productCategoryMapper.selectList(queryWrapper);
        return  PageInfo.of(courselist);
    }
}
